package com.example.myblog.dao;

import com.example.myblog.pojo.User;
import org.apache.ibatis.annotations.*;
import java.util.List;

/**
 * @BelongsProject: MyBlog
 * @BelongsPackage: com.example.myblog.dao
 * @ClassName UserDao
 * @CreateTime: 2025-05-28  22:57
 * @Author: TangLiFei
 */
@Mapper
public interface UserDao {
    List<User> findUserWithAuthorities(String account, String pwd);
    public User findUserByAccountAndPwd(User user);
    public void insertUser(User user);
    //查询所有用户
    @Select("SELECT * FROM t_account")
    List<User> findAllUsers();
    //注销用户
    @Delete("DELETE FROM t_account WHERE id = #{id}")
    void deleteUserById(int id);
    //按用户名查询用户
    @Select("SELECT * FROM t_account WHERE account = #{account}")
    User findByAccount(String account);
    //关联注册用户时并添加权限信息
    @Insert("INSERT INTO t_account_authority (account_id, authority_id) VALUES (#{accountId}, #{authorityId})")
    void insertAccountAuthority(@Param("accountId") int accountId, @Param("authorityId") int authorityId);
    String mapAuthorities(int authorityId);
}
